package admin

import (
	"github.com/spf13/cast"
	"hello/app/http/controllers"
	"hello/app/models"
	"hello/lib/view"
	"net/http"
)

type Category struct {
	controllers.Base
	BaseModel models.CategoryModel
}

func NewCategory() Category {
	return Category{}
}

//Index 栏目列表页面
func (c *Category) Index(w http.ResponseWriter, r *http.Request) {
	fileName := "admin/category/index"
	view.Render(w, view.D{}, fileName)
}

//GetList 栏目列表数据
func (c *Category) GetList(w http.ResponseWriter, r *http.Request) {
	gets := r.URL.Query()
	page := cast.ToInt(gets.Get("page"))
	all, count, err := c.BaseModel.GetAll(page)
	if err != nil {
		c.ErrorJson(w, "", err.Error())
	}
	c.LayuiSuccessJson(w, all, "", count)
}

//添加页面
func (c Category) Create() {

}

//保存添加
func (c Category) Store() {

}

//修改页面
func (c Category) Edit() {

}

//保存修改
func (c Category) Update() {

}

//删除
func (c Category) Delete() {

}
